<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<header class="am-topbar am-topbar-inverse" style="padding: 0;margin: 0;">
    <div class="main">
        <h1 class="am-topbar-brand">
            <a href="#">${applicationScope.ojName}</a>
        </h1>

        <div class="am-collapse am-topbar-collapse" id="doc-topbar-collapse">
            <ul class="am-nav am-nav-pills am-topbar-nav">
                <li class="index">
                    <a href="${pageContext.request.contextPath}/index.html">首页</a>
                </li>
                <li class="problemset">
                    <a href="${pageContext.request.contextPath}/problemset.html">题目</a>
                </li>
                <li class="status">
                    <a href="${pageContext.request.contextPath}/status.html">状态</a>
                </li>
                <li class="ranklist">
                    <a href="${pageContext.request.contextPath}/ranklist.html">排名</a>
                </li>
                <li class="contest">
                    <a href="${pageContext.request.contextPath}/contest.html">竞赛&amp;作业</a>
                </li>
            </ul>

            <div class="am-topbar-right">
                <div class="am-dropdown" data-am-dropdown="{boundary: '.am-topbar'}">
                    <button class="am-btn am-btn-secondary am-topbar-btn am-btn-sm am-dropdown-toggle"
                            data-am-dropdown-toggle>其他 <span class="am-icon-caret-down"></span></button>
                    <ul class="am-dropdown-content">
                        <li class="contestlist">
                            <a href="${pageContext.request.contextPath}/contestlist.html">最近联赛</a>
                        </li>
                        <li class="faqs">
                            <a href="${pageContext.request.contextPath}/faqs.html">常见问题</a>
                        </li>
                        <li class="discuss">
                            <a href="${pageContext.request.contextPath}/discuss.html">论坛</a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="am-topbar-right">
                <c:choose>
                    <c:when test="${sessionScope.user eq null}">
                        <a href="#"
                           id="login"
                           class="am-btn am-btn-primary am-topbar-btn am-btn-sm">登录 / 注册 </a>
                    </c:when>
                    <c:otherwise>
                        <a href="${pageContext.request.contextPath}/userinfo.html"
                           class="am-btn am-btn-primary am-topbar-btn am-btn-sm">${sessionScope.user.nick}</a>
                    </c:otherwise>
                </c:choose>
            </div>
        </div>
    </div>
</header>

<script src="js/jquery.min.js"></script>
<script>
    $(function () {
        $('#login').click(function () {
            var url = window.location.href;
            window.location.href = "${pageContext.request.contextPath}/login.html?from=" + url;
        });
    })
</script>